package msfgui;

/**
 *
 * @author scriptjunkie
 */
public class SearchDwldOptionsDialog extends OptionsDialog {

    /** Creates new form SearchDwldOptionsDialog */
    public SearchDwldOptionsDialog(java.awt.Frame parent, String currentDir) {
        super(parent, "Schedule Task Options", true);
        initComponents();
		dirField.setText(currentDir);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        okButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        dirField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        officeButton = new javax.swing.JRadioButton();
        win9xButton = new javax.swing.JRadioButton();
        passButton = new javax.swing.JRadioButton();
        customButton = new javax.swing.JRadioButton();
        customField = new javax.swing.JTextField();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(SearchDwldOptionsDialog.class);
        okButton.setText(resourceMap.getString("okButton.text")); // NOI18N
        okButton.setName("okButton"); // NOI18N
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        dirField.setText(resourceMap.getString("dirField.text")); // NOI18N
        dirField.setName("dirField"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        buttonGroup1.add(officeButton);
        officeButton.setSelected(true);
        officeButton.setText(resourceMap.getString("officeButton.text")); // NOI18N
        officeButton.setName("officeButton"); // NOI18N

        buttonGroup1.add(win9xButton);
        win9xButton.setText(resourceMap.getString("win9xButton.text")); // NOI18N
        win9xButton.setName("win9xButton"); // NOI18N

        buttonGroup1.add(passButton);
        passButton.setText(resourceMap.getString("passButton.text")); // NOI18N
        passButton.setName("passButton"); // NOI18N

        buttonGroup1.add(customButton);
        customButton.setText(resourceMap.getString("customButton.text")); // NOI18N
        customButton.setName("customButton"); // NOI18N

        customField.setText(resourceMap.getString("customField.text")); // NOI18N
        customField.setName("customField"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(customButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(customField, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE))
                    .addComponent(passButton)
                    .addComponent(win9xButton)
                    .addComponent(officeButton)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dirField, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE))
                    .addComponent(jLabel2)
                    .addComponent(okButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(dirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(officeButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(win9xButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(passButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(customButton)
                    .addComponent(customField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addComponent(okButton)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
		StringBuilder cmd = new StringBuilder("search_dwld \""+MsfguiApp.doubleBackslashes(dirField.getText())+"\"");
		if(officeButton.isSelected())
			cmd.append(" office");
		else if(win9xButton.isSelected())
			cmd.append(" win9x");
		else if(passButton.isSelected())
			cmd.append(" passwd");
		else if(customButton.isSelected())
			cmd.append(" free "+customField.getText());
		command = cmd.toString();
		doClose();
    }//GEN-LAST:event_okButtonActionPerformed

    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        doClose();
    }//GEN-LAST:event_closeDialog

    private void doClose() {
        setVisible(false);
        dispose();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton customButton;
    private javax.swing.JTextField customField;
    private javax.swing.JTextField dirField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JRadioButton officeButton;
    private javax.swing.JButton okButton;
    private javax.swing.JRadioButton passButton;
    private javax.swing.JRadioButton win9xButton;
    // End of variables declaration//GEN-END:variables

}
